#include<iostream>
#include<algorithm>
// 特别小心下标是从1 开始
using namespace std;

const int MAX_M = 15, MAX_N = 1010;
const int SIZE = MAX_M+MAX_N;

int main(int argc, char const *argv[])
{
    freopen("test.txt","r",stdin);
    int N,M,K,D; cin>>N>>M>>K>>D;
    int e[SIZE][SIZE]; fill(e[0],e[0]+SIZE*SIZE,INT32_MAX);
    // input
    // 1,..,N, N+1(G1),...,N+M(GM) => [1,N+M]
    for(int _=0;_<K;++_)
    {
        int a[3];
        for(int j = 0;j<3;++j)
        {
            char s[10]={0}; scanf("%s",s);
            if(s[0] == 'G')
            {
                sscanf(s+1,"%d",a+j);
                a[j] += N;
            }
            else sscanf(s,"%d",a+j);
        }
        e[a[0]][a[1]] = e[a[1]][a[0]] = a[2];
    }
    // 对下标为[N+1,N+M]的点，run dijk
    int pl[MAX_M][SIZE];fill(pl[0],pl[0]+MAX_M*SIZE,INT32_MAX);
    int plmin[MAX_M];fill(plmin,plmin+M,INT32_MAX);
    for(int i = N+1;i<=N+M;++i)
    {
        int visited[SIZE]={0};
        pl[i-1-N][i] = 0;
        for(int _ = 0;_<N+M;++_)
        {
            // find minid
            int minid=0, minpl=INT32_MAX;
            for(int j = 1;j<=N+M;++j)
            {
                if(!visited[j] && pl[i-1-N][j] < minpl)
                    { minpl = pl[i-1-N][j]; minid = j; }
            }
            if(minid)   // assume graph is connected
            {
                visited[minid] = 1;
                if(minpl && minid<=N &&minpl < plmin[i-1-N])
                    plmin[i-1-N] = minpl;         
                if(minid<=N && minpl > D)
                    { plmin[i-1-N] = -1; break; }
                // update
                for(int j = 1;j<=N+M;++j)
                {
                    if(!visited[j] && e[minid][j] < INT32_MAX && pl[i-1-N][minid] + e[minid][j]<pl[i-1-N][j])
                        pl[i-1-N][j] = pl[i-1-N][minid] + e[minid][j];
                }
            }
        }
    }

    int maxplmin = *(max_element(plmin,plmin+M));
    if(maxplmin==-1) cout<<"No Solution\n";
    else
    {
        int minallpl = INT32_MAX; int res = 0;
        for(int i = 0;i<M;++i)
        {
            if(plmin[i] == maxplmin)
            {
                int tmp = 0; for(int j = 1;j<=N;++j) tmp += pl[i][j]; 
                if(tmp < minallpl) {res = i;minallpl = tmp;}
            }
        }    
        printf("G%d\n",res+1);
        printf("%.1f %.1f\n", 1.*plmin[res],(int)((10.*minallpl)/N + 0.5) / 10.);
    }
    return 0;
}
